<?php
header ("Content-type: image/png");
include 'jr.php';
mb_internal_encoding("UTF-8"); // 设置编码
function autowrap($fontsize, $angle, $fontface, $string, $width) {
// 这几个变量分别是 字体大小, 角度, 字体名称, 字符串, 预设宽度
 $content = "";
 // 将字符串拆分成一个个单字 保存到数组 letter 中
 for ($i=0;$i<mb_strlen($string);$i++) {
  $letter[] = mb_substr($string, $i, 1);
 }
 foreach ($letter as $l) {
  $teststr = $content." ".$l;
  $testbox = imagettfbbox($fontsize, $angle, $fontface, $teststr);
  // 判断拼接后的字符串是否超过预设的宽度
  if (($testbox[2] > $width) && ($content !== "")) {
   $content .= "\n";
  }
  $content .= $l;
 }
 return $content;
}
$time=date("Y-m-d H:i:s",time()); 
$bg = imagecreatetruecolor(690, 480); // 创建画布
$white = imagecolorallocate($bg, 255, 255, 255); // 创建白色
$ab=date('l dS of F Y h:i A');
$text = "\n\n\n\n\n\n\n\n历史上的今日:\n".$jieguo."\n\n\nPowered by ecer\n".$ab."\n\n\n\n\n\n\n\n\n\n\n\n";
$text = autowrap(12, 0, "simsun.ttc", $text, 680); // 自动换行处理
// 若文件编码为 GB2312 请将下行的注释去掉
// $text = iconv("GB2312", "UTF-8", $text);
imagettftext($bg, 12, 0, 10, 30, $white, "simsun.ttc", $text);
imagepng($bg,'test.png');
imagedestroy($bg);
?>